﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Text;

namespace Open.Data.Persistence
{
    //Abstract class defining mehods and properties to direct rows of storage data to query objects
    public abstract class QueryDataAdapter: IDisposable
    {
        private Command _command;
        private List<BinderInfo> _dataBinders;
        private Dictionary<Type, TypeInfo> _types;

        //Constructors
        public QueryDataAdapter(Command command)
        {
            _command = command;
            Reset();
        }

        //Properties
        public virtual Command Command
        {
            get
            {
                return _command;
            }
        }

        public virtual List<BinderInfo> DataBinders
        {
            get
            {
                return _dataBinders;
            }
            set
            {
                _dataBinders = value;
            }
        }

        public virtual Dictionary<Type, TypeInfo> Types
        {
            get
            {
                return _types;
            }
            set
            {
                _types = value;
            }
        }

        //Methods
        public virtual void Reset()
        {
            _dataBinders = new List<BinderInfo>();
            _types = null;
        }   
    
        public abstract void AddDataBinder<T>(DataBinder<T> binder)
            where T : class, IPersistable, new();
        public abstract bool Read();
        public abstract void Initialise();
        public abstract List<T> CreateList<T>(IDataBinder binder)
            where T: class, IPersistable;
        public abstract void Dispose();


    }
}
